#include "widget.h"
#include "ui_widget.h"
#include<windows.h>
#include<thread>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

//    int val = ui->lcdNumber->intValue();

//    while (true) {
//        std::this_thread::sleep_for(std::chrono::seconds(1));//休眠一秒
//        if(val<=0)
//        {
//            break;
//        }
//        val--;
//        ui->lcdNumber->display(--val);
//    }

    std::thread t([this](){
        int val = this->ui->lcdNumber->intValue();
        while (true) {
            std::this_thread::sleep_for(std::chrono::seconds(1));
            if(val<=0)
            {
                break;
            }
            val--;
            ui->lcdNumber->display(val);//修改界面
        }
    });
}

Widget::~Widget()
{
    delete ui;
}

